package com.project.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.project.entity.SupplierEntity;
import com.project.entity.TenderEntity;
import com.project.mapper.ISupplierMapper;
import com.project.mapper.ITenderMapper;
import com.project.service.ISupplyInfoMonitor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class SupplyInfoMonitor implements ISupplyInfoMonitor {

    @Autowired
    private ISupplierMapper mapper;

    @Autowired
    private ITenderMapper tenderMapper;

    @Override
    public List<SupplierEntity> findAll() {
        return mapper.selectList(null);
    }

    @Override
    public SupplierEntity findById(Integer id) {
        SupplierEntity s=mapper.selectById(id);
        QueryWrapper<TenderEntity> qw = new QueryWrapper<>();
        qw.eq("t_tenderRef",s.getId());
        List<TenderEntity> tenderEntityList =tenderMapper.selectList(qw);
        s.setTenderEntityList(tenderEntityList);
        return s;
    }
}
